﻿ var id = getvl("id");
 var currentPage=1;
 $(function(){
 	   if(id!=''){
 	   	selectGoodsList2(id);
 	  var si='<a href="39.0.0sell_dingdan_daituikuan_detail.html?id='+id+'">原订单详情</a>';
 	   	$("#digndan").html(si);
 	   }else{
 	   	
 	   }
 });


function  selectGoodsList2(ids){ 

		$.ajax({
             url: urlcore + "/api/refundOrder/selectOneDetails?orderid="+ids,
            type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var da =data.data;
			var	zhuangtai='<h5>'+
		 '<div class="mid-width">'+
			'<span>订单状态</span>';
			if(data.data.order.status==10){
			zhuangtai+='<em>退款成功</em>';
			}else if(ata.data.order.status==9){
			zhuangtai+='<em>已完成</em>';
			}else if(ata.data.order.status==8){
				zhuangtai+='<em>申请退款</em>';
			}
				
			
		zhuangtai+='</div>'+
	'</h5>'+
	'<ul style="padding: 10px;">'+
		'<li>'+
			'<span>退款金额</span>'+
			'<em>'+da.refundMoney+'元</em>'+
		'</li>'+
		'<li>'+
			'<span>结束时间</span>'+
			'<em>'+da.uptDatetime+'</em>'+
		'</li>'+
	'</ul>';
	            $("#zhuangtai").html(zhuangtai);
	            
	var digndanxinxi='<div class="sell_detail_tui">'+
		'<span>买家名称</span>'+
		'<em>'+da.user.userName+'</em>'+
		'<a href="tel:'+da.user.phone+'">联系买家</a>'+
	'</div>'+
	'<ul>'+
		'<li>'+
			'<span>退款单号</span>'+
			'<em id="biao1">'+da.orderNumber+'</em>'+
			'<i class="copy">复制退款单号</i>'+
		'</li>'+
		'<li>'+
			'<span>操作时间</span>'+
			'<em>'+da.gmtDatetime+'</em>'+
		'</li>'+
		'<li>'+
			'<span>处理方式</span>';
			if(da.refundType==2){
				digndanxinxi+='<em>申请退款</em>';
			}else{
				digndanxinxi+='<em>退款退货</em>';
			}
			
			digndanxinxi+='</li>'+
		'<li>'+
			'<span>退款金额</span>'+
			'<em>'+da.refundMoney+'元</em>'+
		'</li>'+
		'<li>'+
			'<span>退款原因</span>'+
			'<em>'+da.refundReason+'</em>'+
		'</li>'+
		'<span>买家留言</span>';
			if(da.refundRemark==null){
				digndanxinxi+='<em></em>';
			}else{
				digndanxinxi+='<em>'+da.refundRemark+'</em>';
			}
				
			digndanxinxi+='</li>'+
		'<div class="clearfix">'+
			'<span>凭证照片</span>';
			
				var attachmentUrl1 = da.refundImg;
	                 		$("#xunhuan").html("");
					if(attachmentUrl1 != null && attachmentUrl1 != '') {
						var imgarr1 = attachmentUrl1.split("***");
						var imgStr2 = '';
						$.each(imgarr1, function(index, value) {
                  digndanxinxi+='<img src="'+value+'" />';
						});
					}
		digndanxinxi+='</div>'+
	'</ul>';
	            $("#digndanxinxi").html(digndanxinxi);
	            
	            $(function(){
	            		 var copyBtn = document.querySelector('.copy')

  // 点击的时候调用 copyTextToClipboard() 方法就好了.
  copyBtn.onclick = function() {
  	var leirongs=$("#biao1").html();
    copyTextToClipboard(leirongs);
  }
    



  function copyTextToClipboard(text) {
   var textArea = document.createElement("textarea")
    textArea.style.position = 'fixed'
    textArea.style.top = 0
    textArea.style.left = 0
    textArea.style.width = '2em'
    textArea.style.height = '2em'
    textArea.style.padding = 0
    textArea.style.border = 'none'
    textArea.style.outline = 'none'
    textArea.style.boxShadow = 'none'
    textArea.style.background = 'transparent'
    textArea.value = text
    document.body.appendChild(textArea)
    textArea.select()
    try {
      var msg = document.execCommand('copy') ? '成功' : '失败'
      console.log('复制内容 ' + msg)
    } catch (err) {
      console.log('不能使用这种方法复制内容')
    }
  document.body.removeChild(textArea)
       }
	            })
	            
	            
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}

				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
		}
	
	
//取消订单
